#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>

int ABC = 0;

void* function_A(void *arg){
	printf("My Name is functionA ,My ID is %d\n", *(int*)arg );
    printf("functionA ABC : %d\n",ABC);
    ABC = 120;

	return arg;
}

void* function_B(void *arg){
    printf("My Name is functionB ,My ID is %d\n", *(int*)arg );
	printf("functionB ABC : %d\n",ABC);
	ABC = 119;
	return arg;
}

void* function_C(void *arg){
    printf("My Name is functionC ,My ID is %d\n", *(int*)arg );
    printf("functionC ABC : %d\n",ABC);
    ABC = 120;

	return arg;
}



void main(){
	pthread_t pth1,pth2,pth3;
	int res = 0;
	int arg1 = 15;
	int arg2 = 50;
	int arg3 = 05;
    int *thread_ret = NULL;  

	printf("This is Main Thread\n");
	res = pthread_create(&pth1 ,NULL , function_A , &arg1);
	if(res != 0 )
		printf("pthreadA create failed\n");

	res = pthread_create(&pth2 ,NULL , function_B , &arg2);
    if(res != 0 )
        printf("pthreadB create failed\n");
    
    res = pthread_create(&pth3 ,NULL , function_C , &arg3);
    if(res != 0 )
        printf("pthreadC create failed\n");



	pthread_join(pth1,(void**)&thread_ret );  
    printf( "threadA_ret = %d.\n", *thread_ret );

	pthread_join(pth2,(void**)&thread_ret );
    printf( "threadB_ret = %d.\n", *thread_ret );

    pthread_join(pth3,(void**)&thread_ret );
    printf( "threadC_ret = %d.\n", *thread_ret );

}

